/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trial.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
 * @author feifei
 */
@Entity

@XmlRootElement
@XmlType(name = "Shop", propOrder = {
    "id",
    "owner",
    "shopName",
    "shopDescription",
    "sellList",
    "orderList",
})


@Table(name = "TRIAL_SHOP",schema="trial")
@NamedQuery(
        name="Shop.findAllShopsOfOneCustomer",
        query="select s from Shop s where s.owner.id=:id"  
           )
public class Shop implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne
    private Customer owner;
    
        
    private String shopName;
    private String shopDescription;
    
    @OneToMany(mappedBy="shop")
    private List<Sell> sellList;
    
    @OneToMany(mappedBy="shop")
    private List<OrderSet> orderList;

    
    public Shop() {
    }

    public Shop(Customer owner) {
        this.owner = owner;
    }

    public Shop(Customer owner, String shopName, String shopDescription) {
        this.owner = owner;
        this.shopName = shopName;
        this.shopDescription = shopDescription;
    }
    
    public String getShopDescription() {
        return shopDescription;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopDescription(String shopDescription) {
        this.shopDescription = shopDescription;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public List<OrderSet> getOrderList() {
        return orderList;
    }

    public void setOrderList(List<OrderSet> orderlist) {
        this.orderList = orderlist;
    }
    
    
    
    public Customer getOwner() {
        return owner;
    }

    public List<Sell> getSellList() {
        return sellList;
    }

    public void setOwner(Customer owner) {
        this.owner = owner;
    }

    public void setSellList(List<Sell> sellList) {
        this.sellList = sellList;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Shop)) {
            return false;
        }
        Shop other = (Shop) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "trial.entity.Shop[ id=" + id + " ]";
    }
    
}
